package com.easycoding.framework.util;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class JsoupUtil {

	/**
	 * 获取Html代码的第一段文字
	 * @param content
	 * @return
	 */
	public static String getHtmlFirstPart(String content){
		Document doc = Jsoup.parse(content.replaceAll("&nbsp;", " "));
		String texts =doc.html(doc.html().replaceAll(" ", "@@@@")).text();
		String[] text = texts.split(" ");
		for(String t:text){
			t = t.replaceAll("@@@@", " ").trim();
			if(!Tool.isEmpty(t)){
				if(t.length()>40)
					return t;
			}
		}
		return "";
	}
}
